package ${package}.${rootArtifactId}.common.util;

import ${package}.${rootArtifactId}.common.model.BaseTableQueryParam;

/**
 * sql工具类
 *
 * @author weidong.lin
 * @date 2021/7/13 16:29
 */
public class SqlUtil {

    /**
     * 设置分页参数
     */
    public static <T extends BaseTableQueryParam> void configOffset(T queryParam) {
        if (queryParam.getPageSize() == null || queryParam.getPageSize() == 0) {
            queryParam.setLimit(30);
        } else {
            queryParam.setLimit(queryParam.getPageSize());
        }
        if (queryParam.getPageNum() == null || queryParam.getPageNum() == 0) {
            queryParam.setOffset(0);
        } else {
            queryParam.setOffset((queryParam.getPageNum() - 1) * queryParam.getLimit());
        }
    }
}
